import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

def draw_bar(path, x_label, y_label):
    df = pd.read_csv(path)
    group = df.groupby(x_label, as_index=False)[y_label].count()
    c_df = pd.DataFrame(group).sort_values(by=y_label, ascending=False)
    print(c_df)

    # 设置坐标文字
    plt.xlabel("Size(cm S:155-160, M:160-165, L:165-170, XL:170-175, 2XL:175-180, 3XL:180-185)")
    plt.ylabel("Quality")

    # 设置数据
    plt.bar(c_df[x_label], c_df[y_label])
    plt.show()

path = '/Users/summer/Documents/Workspace/Data/集中班.csv'
x_label = '尺码'
y_label = '考生姓名'
draw_bar(path, x_label, y_label)
